
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CureMedicine;
import cn.edu.scau.cmi.hombio.domain.CureMethod;
import cn.edu.scau.cmi.hombio.domain.CureTaskCourse;
import cn.edu.scau.cmi.hombio.domain.CureType;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class CureMethodServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CureMethodService service;

	/**
	 * Instantiates a new CureMethodServiceTest.
	 *
	 */
	public CureMethodServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMedicine entity
	* 
	 */
	@Test
	public void saveCureMethodCureMedicines() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMethodCureMedicines 
		Integer id = 0;
		CureMedicine related_curemedicines = new cn.edu.scau.cmi.hombio.domain.CureMedicine();
		CureMethod response = null;
		response = service.saveCureMethodCureMedicines(id, related_curemedicines);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMethodCureMedicines
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMethod entity
	* 
	 */
	@Test
	public void deleteCureMethod() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMethod 
		CureMethod curemethod = new cn.edu.scau.cmi.hombio.domain.CureMethod();
		service.deleteCureMethod(curemethod);
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureType entity
	* 
	 */
	@Test
	public void deleteCureMethodCureType() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMethodCureType 
		Integer curemethod_id = 0;
		Integer related_curetype_id = 0;
		CureMethod response = null;
		response = service.deleteCureMethodCureType(curemethod_id, related_curetype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMethodCureType
	}

	/**
	 * Operation Unit Test
	* Load an existing CureMethod entity
	* 
	 */
	@Test
	public void loadCureMethods() {
		Set<CureMethod> response = null;
		response = service.loadCureMethods();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCureMethods
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCureMethodByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCureMethodByPrimaryKey 
		Integer id_1 = 0;
		CureMethod response = null;
		response = service.findCureMethodByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findCureMethodByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void saveCureMethodCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMethodCureTaskCourse 
		Integer id_2 = 0;
		CureTaskCourse related_curetaskcourse = new cn.edu.scau.cmi.hombio.domain.CureTaskCourse();
		CureMethod response = null;
		response = service.saveCureMethodCureTaskCourse(id_2, related_curetaskcourse);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMethodCureTaskCourse
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void deleteCureMethodCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMethodCureTaskCourse 
		Integer curemethod_id_1 = 0;
		Integer related_curetaskcourse_id = 0;
		CureMethod response = null;
		response = service.deleteCureMethodCureTaskCourse(curemethod_id_1, related_curetaskcourse_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMethodCureTaskCourse
	}

	/**
	 * Operation Unit Test
	* Return all CureMethod entity
	* 
	 */
	@Test
	public void findAllCureMethods() {
		// TODO: JUnit - Populate test inputs for operation: findAllCureMethods 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CureMethod> response = null;
		response = service.findAllCureMethods(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCureMethods
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMethod entity
	* 
	 */
	@Test
	public void saveCureMethod() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMethod 
		CureMethod curemethod_1 = new cn.edu.scau.cmi.hombio.domain.CureMethod();
		service.saveCureMethod(curemethod_1);
	}

	/**
	 * Operation Unit Test
	* Return a count of all CureMethod entity
	* 
	 */
	@Test
	public void countCureMethods() {
		Integer response = null;
		response = service.countCureMethods();
		// TODO: JUnit - Add assertions to test outputs of operation: countCureMethods
	}

	/**
	 * Operation Unit Test
	* Save an existing CureType entity
	* 
	 */
	@Test
	public void saveCureMethodCureType() {
		// TODO: JUnit - Populate test inputs for operation: saveCureMethodCureType 
		Integer id_3 = 0;
		CureType related_curetype = new cn.edu.scau.cmi.hombio.domain.CureType();
		CureMethod response = null;
		response = service.saveCureMethodCureType(id_3, related_curetype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureMethodCureType
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMedicine entity
	* 
	 */
	@Test
	public void deleteCureMethodCureMedicines() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureMethodCureMedicines 
		Integer curemethod_id_2 = 0;
		Integer related_curemedicines_id = 0;
		CureMethod response = null;
		response = service.deleteCureMethodCureMedicines(curemethod_id_2, related_curemedicines_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureMethodCureMedicines
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
